//图片服务url
// export const IMAGE_DOMAIN = 'http://172.17.20.34:90/';
export const IMAGE_DOMAIN = 'http://10.10.90.99:8081/';
//API服务url
export const SERVER_DOMAIN = 'http://172.17.20.88:8081';
// export const SERVER_DOMAIN = 'http://10.10.90.99:8081';
export const SERVER_PATH = `${ SERVER_DOMAIN }/dist/`;
export const apiURl = `${ SERVER_DOMAIN }/api/rest/api/v6.0`;
//微信appid
export const publicWXAppID = "wx2a29d7c7b3575fc6";
export const APPSECRECT = "bd6a1e695c6c7886e8fc4bd349de006c";
export function getFullUrl(requestUrl) {
    let url = apiURl;
    if (requestUrl.startsWith('/')) {
        url += requestUrl;
    } else {
        url = `${url}/${requestUrl}`;
    }
    return url;
}

export function isWechat() {
    return navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1;
}

export function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
// 获取token
export function getToken() {
    return localStorage.getItem('token');
}
export function isQQ() {
    return navigator.userAgent.indexOf('QQ') > -1;
}
/**
 * 去登录
 * @param {登录成功返回的页面} callBack
 */
export function gotoWechat(url) {
    // if(url=="")
    window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + publicWXAppID + "&redirect_uri=" + encodeURIComponent(SERVER_DOMAIN) + "&response_type=code&scope=snsapi_userinfo&state=weixin#wechat_redirec";
    // else window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + publicWXAppID + "&redirect_uri=" + url + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirec";
}
export function gotoQuietWechat(url) {
    if (url == "") window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + publicWXAppID + "&redirect_uri=" + SERVER_DOMAIN + "&response_type=code&scope=snsapi_base&state=weixin#wechat_redirec";
    else window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + publicWXAppID + "&redirect_uri=" + url + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirec";
}
export function getPath() {
    let strFullPath = window.document.location.href;
    let strPath = window.document.location.pathname;
    let pos = strFullPath.indexOf(strPath);
    let prePath = strFullPath.substring(0, pos);
    return prePath;
}
export function gotoLogin(callBack) {
    // if (!isWechat()) {
    if (callBack) {
        window.location.href = getPath() + "/login" + "?callBack=" + callBack;
    } else {
        window.location.href = 'login';
    }
    return;
    // } else {
    //     gotoWechat();
    // }
}
/**
 * 去登录回调
 */
export function gotoLoginAndBack() {
    // 获取当前URL,作为登录回调
    const currentUrl = window.location.href;
    gotoLogin(encodeURIComponent(currentUrl));
}
// export const rgModelEndLoadCp = (app, modelUrlArr, componentUrl) => {
//   return dynamic({
//     app,
//     models: () => {
//      const modelArr = modelUrlArr.map((v,i,a)=>{
//         import(v).then(model=>{
//           if (!(app._models.filter(m => m.namespace === model.namespace).length === 1)) {
//             return model
//           }
//         })
//       });
//       return [ ...modelArr ]
//     }
//     ,
//     component: () => import(componentUrl),
//   });
// }


//
// export const registerModel = (app, model) => {
//   if (!(app._models.filter(m => m.namespace === model.namespace).length === 1)) {
//     app.model(model);
//   }
// }


//
// export  function setCookie(name,value,time) {
//   var strsec = getsec(time);
//   var exp = new Date();
//   exp.setTime(exp.getTime() + strsec*1);
//   document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
// }
// function getsec(str) {
//   var str1=str.substring(1,str.length)*1;
//   var str2=str.substring(0,1);
//   if (str2=="s")
//   {
//     return str1*1000;
//   }
//   else if (str2=="h")
//   {
//     return str1*60*60*1000;
//   }
//   else if (str2=="d")
//   {
//     return str1*24*60*60*1000;
//   }
// }
// //这是有设定过期时间的使用示例：
// //s20是代表20秒
// //h是指小时，如12小时则是：h12
// //d是天数，30天则：d30
// //setCookie("name","hayden","s20");
//
//
// export  function getCookie(c_name) {
//   if (document.cookie.length>0) {
//     let c_start=document.cookie.indexOf(c_name + "=")
//     if (c_start!=-1) {
//       c_start=c_start + c_name.length+1
//       let c_end=document.cookie.indexOf(";",c_start)
//       if (c_end==-1) c_end=document.cookie.length
//       return unescape(document.cookie.substring(c_start,c_end))
//     }
//     return false
//   }
//   return false
// }
